Remove everything except alphanumeric charsΒΆ

Remove everything except alphanumeric characters from a string.
import re

S = '**//Python Exercises// - 12. '

pattern = re.compile('[\W_]+')

print(pattern.sub('', S))

Output:

PythonExercises12